package com.mall.sso.web.controller;


import com.alibaba.dubbo.config.annotation.Reference;
import com.mall.manager.pojo.TbUser;
import com.mall.pojo.TaotaoResult;
import com.mall.sso.service.RegisterService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author Administrator
 */
@Controller
public class RegisterController {

    @Reference
    RegisterService userService;

    @GetMapping("/user/check/{param}/{type}")
    @ResponseBody
    public TaotaoResult checkUser(@PathVariable("param") String param, @PathVariable("type") int type){
        TaotaoResult taotaoResult = userService.checkUserData(param, type);
        taotaoResult.setData(((boolean) taotaoResult.getData()));
        return taotaoResult;
    }


    @PostMapping("/user/register")
    @ResponseBody
    public TaotaoResult register(TbUser user){
        TaotaoResult taotaoResult = userService.register(user);
        return taotaoResult;
    }

}
